import xml.dom.minidom
import socket
import time
from client import *
from receiver import *
from sender import * 
from queue_listener import * 
from multiplexer import * 
from play_listener import * 
from pause_listener import *
from rhythmbox import *
from client_sender import *

from Queue import *

rhy = Rhythmbox()

doc = xml.dom.minidom.parse(rhy.getLibraryFile())

clt = Client("nax-laptop", doc)

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 12345))

receiver = Receiver(sock)
sender = Sender(sock)

queue = Queue()
qlst = QueueListener(queue, receiver)
multi = Multiplexer(queue)

pl = PlayListener(rhy)
paus = PauseListener(rhy)
multi.addListener(pl)
multi.addListener(paus)

multi.setDaemon(True)
receiver.setDaemon(True)
multi.start()
receiver.start()

sender.send(ClientSender(clt))

while 1:	
	time.sleep(1)
	pass
